import random
from sqlalchemy import Table
from common.database import db_connent
db_session,Base,engine = db_connent()

class User(Base):
    __table__ = Table("user", Base.metadata, autoload_with=engine)
    def get_one(self):
        return db_session.query(User).first()
    def find_dy_suername(self,username):
        db_session.query(User).filter_by(username=username).all()

    def bo_register(self,username,password):
        nickname = username.split("@")[0]
        picture_num = random.randint(1,539)
        picture = str(picture_num)+".jpg"
        job = "未定义"
        user = (User(username=username,password=password,nickname=nickname,picture=picture,job=job))
        db_session.add(user)
        db_session.commit()
        return user


























